package it.polimi.digitalstate.webbeans;

import it.polimi.digitalstate.manager.AuthenticationManagerLocal;
import it.polimi.digitalstate.manager.ElectionManagerLocal;
import it.polimi.digitalstate.manager.MembershipManagerLocal;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.ejb.EJB;

import managerexception.CannotSubmitMembership;


@ManagedBean(name="governorPersonalPageBean")
@RequestScoped
public class GovernorPersonalPageBean {
	@EJB
	private MembershipManagerLocal ejb_memmanager;
	private int pnumberadded;
	
	public String endCandidacy() {
		int added = 0;
		try {
			added = ejb_memmanager.governorEndCandidacy();
		} catch(CannotSubmitMembership e)
		{ return "candidacyenderror.xhtml?faces-redirect=true&numberadded="+e.getNumberAdded();}
		
		return "candidacyenddone.xhtml?faces-redirect=true&numberadded="+added;
	}

	public int getPnumberadded()
	{
		return pnumberadded;
	}
	public void setPnumberadded(int pnumberadded)
	{
		this.pnumberadded = pnumberadded;
	}
}
